package com.ying.tests.AAAmode.singleton;

/**
 * 单例模式：懒汉
 */
public class LazySingleton {

    // 保证该实例在所有线程中同步
    private static volatile LazySingleton instance = null;

    private LazySingleton() {
        // 避免类在外部被实例化
    }

    public synchronized LazySingleton getInstance() {
        if (null == instance) {
            instance = new LazySingleton();
        }
        return instance;
    }

}
